﻿
// JavaScript Document

	 var mydiv;     //需要显示的div
	 var weatherdiv;// 显示天气的div
	 var  texts;
	 var fcolor;
	 var day;
	 var context;  //div中的内容
	 var loop ;  //loop指向setInterval函数，用来控制停止
	 var color_desc_div;//颜色描述div
	 var start = 0;
	 var logo;
	 var trangle = 10;
	 var timerbomo;
	 window.onload = function(){
	 	mydiv = document.getElementById('text-div');
		weatherdiv = document.getElementById('weather-div');
		logo = document.getElementById("play_btn");
	 	context = document.getElementById("hidden-div").innerHTML;
		initColor();
		initTexts();
		mydiv.innerHTML = "";
		mydiv.style.color = fcolor;
	 }
	 

	 function typing(){
	 	
			mydiv.innerHTML = context.substring(0,start++) + "_";
			if(start == context.length){
				clearInterval(loop);
				mydiv.innerHTML = context;
				
			}
	 };

	 function mouseOverFn(){
	
	 }
	 
	 function mouseOutFn(){
		
	 }
	 
	 function mouseClickFn(){
		 
		$('#play_btn').fadeOut(1700,0);
		logo.id='btn123';
		$('#bg').slideUp(3000,0,startWork);
		timerbomo = setInterval(xuanzhuan,1);
	 }	
	 
	 function xuanzhuan(){
	
		trangle = trangle - 20;
		document.getElementById('btn123').style.transform='rotate('+trangle+'deg)';
	 }
	 
	 function startWork(){
		clearInterval(timerbomo);
		setTimeout("$('#music-div').slideDown(1500)",1500);
		loop = setInterval("typing()",160);
		setWeather();
		initColor();
	 }
	 /*
红  #F00
橙  #F60
黄  #FF0
绿  #0C3
紫  #606
黑  #000
白  #FFF
	 */
	 
	 function initColor(){
	 	var d=new Date();
		var weekday=new Array(7);
		var colors = new Array(7);
		weekday[0]="星期日";
		weekday[1]="星期一";
		weekday[2]="星期二";
		weekday[3]="星期三";
		weekday[4]="星期四";
		weekday[5]="星期五";
		weekday[6]="星期六";
		colors[0] = "#F00";
		colors[1] = "#F60";
		colors[5] = "#FF0";
		colors[3] = "#0C3";
		colors[4] = "#606";
		colors[2] = "#C6F";
		colors[6] = "#FFF";
		fcolor = colors[d.getDay()];
		day = weekday[d.getDay()];
	 }
	 
	 function setWeather(){
		 var result;
		 var today = new Date();
		 var riqi = '<font color="' + fcolor + '">' + today.getFullYear() + '年' +(today.getMonth()+1) + '月' + today.getDate() + '日&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' + day+ '</font></br>';
	 	 	
		 var coldiv = '<div onMouseOut="clearColorDesc()"; onMouseOver="showColorDesc()"; style="width:40px; height:20px; background:' + fcolor + '"></div>'
		 var coldesc = '<div id="coldesc" style="font-size:12px; margin-top:5px;width:60%"  >字体颜色每天都在变，愿你的生活也如此般多彩,lalala~~~</div>';
		weatherdiv.innerHTML = riqi +coldiv + coldesc;
	 }
	 
	 function initTexts(){
	 	texts = new Array(7);
		texts[0] = '红色热情，活泼，张扬，欢乐。  ';
		texts[1] = '橙色时尚，青春，动感，活力。';
		texts[5] = '黄色灿烂、辉煌，智慧，骄傲。';
	 	texts[3] = '绿色清新，健康，希望，生机。';
	 	texts[4] = '紫色可爱，神秘，高贵，愉快。';
	 	texts[2] = '粉色可爱，温馨，娇嫩，明快。';
		texts[6] = '白色清爽，无瑕，冰雪，简单。';
	 }
	 
	 function getColorDesc(day){
		return texts[day];
	 }
	 
	 function showColorDesc(){
	 	color_desc_div = document.getElementById('coldesc');
		color_desc_div.style.color = fcolor;
		color_desc_div.innerHTML = getColorDesc(new Date().getDay());
	 }
	 
	 function clearColorDesc(){
		color_desc_div = document.getElementById('coldesc');
		
		color_desc_div.innerHTML = "字体颜色每天都在变，愿你的生活也如此般多彩,啦啦啦~~~";
	}
	
	